import sqlite3 as db
import os
from lib.InitDB import InitDB
from lib.SQL import SQL
import xlrd
import datetime



'''
以后删除都加上软删除，在所有表中多加一列isDelete 表示删除符
'''
path = './data/test.db'
newADatabase = 0

if newADatabase == 1:
    a = InitDB(path)
    a.newDatabase()

table_bank = {
'id':'',
'name':'',
'cardNum':'',
'balance':'',
'isCredit':'',
'creditBalance':'',
'accountDay':'',
'interestFree':'',
'pic':'',
'brand':'',
'expireDay':'',
'commands':'',
'isDeleted':''
                        }
table_channel = {
'id':'',
'level':'',
'channelNameP':'',
'channelNameS':'',
'isSelf':'',
'type':'',
'tax':'',
'bankNum':'',
'pic':'',
'commands':'',
'isDeleted':''
}
table_accountBook = {
'id':'',
'date':'',
'bankNum':'',
'channeName':'',
'amount':'',
'booked':'',
'bookedDate':'',
'isExpense':'',
'commands':''
}

sql1 = SQL(path)

importExcel1 = r'e:\A_Code\GIT\Requirement_Management\小账本\accountBook\导入数据.xls'
sql1.importExcelDate(table1 = 'bank', importExcel = importExcel1, tableDict = table_bank)

table1 = 'accountBook'
table_accountBook['id'] = sql1.mySequenceNextValue(table1+'_id_seq')

table_accountBook['date'] = sql1.currentTime()
print(table_accountBook['date'])
sql1.mySave(table = table1, datas = table_accountBook)
print(sql1.myFetch(table=[table1], columns=['date'], conditions={'id':'1'}))







